﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsKetChuyenChiPhi
    {
        private string mDienGiai = "";
        private string mKhoaBoPhanCo = "";
        private string mKhoaBoPhanNo = "";
        private string mKhoaChungTu = "";
        private string mKhoaDoiTuongCo = "";
        private string mKhoaDoiTuongNo = "";
        private string mKhoaDonVi = "";
        private string mKhoaHopDongCo = "";
        private string mKhoaHopDongNo = "";
        private string mKhoaKhoanMucCo = "";
        private string mKhoaKhoanMucNo = "";
        private string mKhoaSanPhamCo = "";
        private string mKhoaSanPhamNo = "";
        private string mKhoaTaiKhoanCo = "";
        private string mKhoaTaiKhoanNo = "";
        private string mLoaiTien = "";
        private string mNamThang = "";
        private string mNgayChungTu = "";
        private int mSend = 0;
        private string mSoChungTu = "";
        private double mSoPhatSinh = 0.0;
        private double mSoPhatSinhNT = 0.0;
        private double mTyGia = 0.0;

        public void ClearTmp(string strKhoa)
        {
            try
            {
                string commandText = "DELETE FROM GL_KetChuyenLaiLoTmp WHERE KhoaChungTu = '" + strKhoa + "'";
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                ProjectData.ClearProjectError();
            }
        }

        public bool DelData(string cFrmKhoaChungTu)
        {
            bool flag=false;
            string commandText = "";
            commandText = "DELETE FROM GL_NhatKyChungTu WHERE KhoaChungTu = '" + cFrmKhoaChungTu + "'";
            try
            {
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetChiPhi()
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[0x1a];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, this.mNamThang);
                commandParameters[2] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_GetChiPhi", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDoanhThu()
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[0x1a];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, this.mNamThang);
                commandParameters[2] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_GetDoanhThu", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTu);
                commandParameters[1] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_KetChuyenLaiLo", commandParameters);
                this.ClearTmp(this.mKhoaChungTu);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(commandParameters[1].Value, 0, false))
                {
                    return false;
                }
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                this.ClearTmp(this.mKhoaChungTu);
                MessageBox.Show(exception.Message);
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool SaveTmp()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[0x17];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, this.mNamThang);
                commandParameters[1] = DBHelper.createParameter("@KhoaChungTu", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTu);
                commandParameters[2] = DBHelper.createParameter("@SoChungTu", DbType.Int64, ParameterDirection.Input, this.mSoChungTu);
                commandParameters[3] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[4] = DBHelper.createParameter("@KhoaTaiKhoanNo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanNo);
                commandParameters[5] = DBHelper.createParameter("@KhoaDoiTuongNo", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongNo);
                commandParameters[6] = DBHelper.createParameter("@KhoaBoPhanNo", DbType.Int64, ParameterDirection.Input, this.mKhoaBoPhanNo);
                commandParameters[7] = DBHelper.createParameter("@KhoaSanPhamNo", DbType.Int64, ParameterDirection.Input, this.mKhoaSanPhamNo);
                commandParameters[8] = DBHelper.createParameter("@KhoaHopDongNo", DbType.Int64, ParameterDirection.Input, this.mKhoaHopDongNo);
                commandParameters[9] = DBHelper.createParameter("@KhoaKhoanMucNo", DbType.Int64, ParameterDirection.Input, this.mKhoaKhoanMucNo);
                commandParameters[10] = DBHelper.createParameter("@KhoaTaiKhoanCo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanCo);
                commandParameters[11] = DBHelper.createParameter("@KhoaDoiTuongCo", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongCo);
                commandParameters[12] = DBHelper.createParameter("@KhoaBoPhanCo", DbType.Int64, ParameterDirection.Input, this.mKhoaBoPhanCo);
                commandParameters[13] = DBHelper.createParameter("@KhoaSanPhamCo", DbType.Int64, ParameterDirection.Input, this.mKhoaSanPhamCo);
                commandParameters[14] = DBHelper.createParameter("@KhoaHopDongCo", DbType.Int64, ParameterDirection.Input, this.mKhoaHopDongCo);
                commandParameters[15] = DBHelper.createParameter("@KhoaKhoanMucCo", DbType.Int64, ParameterDirection.Input, this.mKhoaKhoanMucCo);
                commandParameters[0x10] = DBHelper.createParameter("@LoaiTien", DbType.Int64, ParameterDirection.Input, this.mLoaiTien);
                commandParameters[0x11] = DBHelper.createParameter("@TyGia", DbType.Date, ParameterDirection.Input, this.mTyGia);
                commandParameters[0x12] = DBHelper.createParameter("@SoPhatSinhNT", DbType.Date, ParameterDirection.Input, this.mSoPhatSinhNT);
                commandParameters[0x13] = DBHelper.createParameter("@SoPhatSinh", DbType.Date, ParameterDirection.Input, this.mSoPhatSinh);
                commandParameters[20] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                commandParameters[0x15] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[0x16] = DBHelper.createParameter("@Send", DbType.Double, ParameterDirection.Input, this.mSend);
                flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_KetChuyenLaiLoTmp", commandParameters) > 0;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public string KhoaBoPhanCo
        {
            get
            {
                return this.mKhoaBoPhanCo;
            }
            set
            {
                this.mKhoaBoPhanCo = value;
            }
        }

        public string KhoaBoPhanNo
        {
            get
            {
                return this.mKhoaBoPhanNo;
            }
            set
            {
                this.mKhoaBoPhanNo = value;
            }
        }

        public string KhoaChungTu
        {
            get
            {
                return this.mKhoaChungTu;
            }
            set
            {
                this.mKhoaChungTu = value;
            }
        }

        public string KhoaDoiTuongCo
        {
            get
            {
                return this.mKhoaDoiTuongCo;
            }
            set
            {
                this.mKhoaDoiTuongCo = value;
            }
        }

        public string KhoaDoiTuongNo
        {
            get
            {
                return this.mKhoaDoiTuongNo;
            }
            set
            {
                this.mKhoaDoiTuongNo = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public string KhoaHopDongCo
        {
            get
            {
                return this.mKhoaHopDongCo;
            }
            set
            {
                this.mKhoaHopDongCo = value;
            }
        }

        public string KhoaHopDongNo
        {
            get
            {
                return this.mKhoaHopDongNo;
            }
            set
            {
                this.mKhoaHopDongNo = value;
            }
        }

        public string KhoaKhoanMucCo
        {
            get
            {
                return this.mKhoaKhoanMucCo;
            }
            set
            {
                this.mKhoaKhoanMucCo = value;
            }
        }

        public string KhoaKhoanMucNo
        {
            get
            {
                return this.mKhoaKhoanMucNo;
            }
            set
            {
                this.mKhoaKhoanMucNo = value;
            }
        }

        public string KhoaSanPhamCo
        {
            get
            {
                return this.mKhoaSanPhamCo;
            }
            set
            {
                this.mKhoaSanPhamCo = value;
            }
        }

        public string KhoaSanPhamNo
        {
            get
            {
                return this.mKhoaSanPhamNo;
            }
            set
            {
                this.mKhoaSanPhamNo = value;
            }
        }

        public string KhoaTaiKhoanCo
        {
            get
            {
                return this.mKhoaTaiKhoanCo;
            }
            set
            {
                this.mKhoaTaiKhoanCo = value;
            }
        }

        public string KhoaTaiKhoanNo
        {
            get
            {
                return this.mKhoaTaiKhoanNo;
            }
            set
            {
                this.mKhoaTaiKhoanNo = value;
            }
        }

        public string LoaiTien
        {
            get
            {
                return this.mLoaiTien;
            }
            set
            {
                this.mLoaiTien = value;
            }
        }

        public string NamThang
        {
            get
            {
                return this.mNamThang;
            }
            set
            {
                this.mNamThang = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public int Send
        {
            get
            {
                return this.mSend;
            }
            set
            {
                this.mSend = value;
            }
        }

        public string SoChungTu
        {
            get
            {
                return this.mSoChungTu;
            }
            set
            {
                this.mSoChungTu = value;
            }
        }

        public double SoPhatSinh
        {
            get
            {
                return this.mSoPhatSinh;
            }
            set
            {
                this.mSoPhatSinh = value;
            }
        }

        public double SoPhatSinhNT
        {
            get
            {
                return this.mSoPhatSinhNT;
            }
            set
            {
                this.mSoPhatSinhNT = value;
            }
        }

        public double TyGia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }
    }
}

